<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>hi 子薇</title>
  <style>
    #a {
      width: 350px;
      height: 350px;
      margin: 150px;
      line-height: 350px;
      background-color: lightblue;
      text-align: center;
      color: #f0f0f0;
      font-size: 30px;
      border-radius: 10px;
      transition: all 0.5s;
      box-shadow: 0 0 20px 6px #ddd;
    }
    #a:hover {
      background-color: rgba(173, 216, 230, 0.801);
    }
  </style>
</head>
<body>
  <div id="a">
    <span id="text">
      Hello World !
    </span>
  </div>
  <div id="b">
    hey ziwei
  </div>

  <script>
    // 1. 选择元素
    var elementA = document.getElementById('text')
    // 2. 打印元素
    console.log(elementA)
    // 3. 设置点击时候的行为
    elementA.onclick = function() {
      var text = elementA.innerText
      if (text === "Hello World !") {
        elementA.innerText = "Hey Ziwei"
      } else {
        elementA.innerText = "Hello World !"
      }
    }
  </script>
</body>
</html>